<?php

function smarty_function_t($params)
{	
	global $setupdata, $mysqlclass, $translate;
	if (isset($params['error'])) $params['t']='error_code_'.$params['error'];
	$rows = array();
	if ((isset($_COOKIE['interface_lang'])) and ($_COOKIE['interface_lang'] != "")) $interface_lang = $_COOKIE['interface_lang'];
	else $interface_lang = $setupdata['default_languages'];	
	
	if (isset($translate[addslashes($params['t'])][strtolower($interface_lang)])){
		if ((isset($setupdata['help_tips_status'])) && ($setupdata['help_tips_status'] == "on") && (isset($translate[addslashes($params['t'])][strtolower('help_'.$interface_lang)]) &&  $translate[addslashes($params['t'])][strtolower('help_'.$interface_lang)]!='')){
			return '<span onMouseOver="fShowTipScreen (\''.stripslashes($translate[addslashes($params['t'])][strtolower('help_'.$interface_lang)]).'\')" onMouseOut="fHideTipScreen ()">'.stripslashes($translate[addslashes($params['t'])][strtolower($interface_lang)]).'</span>';
		} else {
			return stripslashes($translate[addslashes($params['t'])][strtolower($interface_lang)]);
		}
	} else {
		if (isset($_SESSION['login_user']) && ($_SESSION['login_user'] > 0)){
			if (isset($setupdata['translate'])){
				$mysqlclass->connect_db('localhost', 'tvssystem', 'omnitel987', 'tvs_cms');	
				$que = mysql_query("select * FROM `tvs_translate` where uniq ='".$params['t']."' and lang='".$interface_lang."'");	
				if (mysql_num_rows($que) == 0) $sql = mysql_query("INSERT INTO `tvs_translate` (`uniq`,`lang`,`value`) VALUES ('".$params['t']."', '".$interface_lang."', '".$params['t']."')");	
				$mysqlclass->connect_db($setupdata['HostName'], $setupdata['UserName'], $setupdata['Password'], $setupdata['DBName']);
			}
		}
		return $params['t'];
	}

}

?>
